<template>
  <div class="withdrawnext" style="width:100%;height:100vh;background:#f7f7f7;">
    <mt-header fixed title="提现">
      <div slot="left">
        <mt-button @click="back()" icon="back"></mt-button>
      </div>
    </mt-header>
    <div style="width:100%;height:.8rem;"></div>
    <div class="withdrawnext_content">
      <div class="content_top">
        <span>到账银行卡</span>
        <span style="color:#666;font-size:.3rem;">{{bankNo}}</span>
      </div>
      <div class="content_input">
        <span>￥</span>
        <input v-model="param.fee" type="text" placeholder="请输入金额">
      </div>
      <div class="withdraw_button">
        <button @click="withdraws()">提现</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      param: {
        fee: ""
      },
      bankNo: ""
    };
  },
  mounted() {
    this.withdraw();
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    withdraws() {
      var that = this;
      if (that.param.fee == "") {
        return that.$message.error("请输入提现金额！");
      }
      if (that.bankNo == "") {
        that.$router.push({ path: "Authentication" });
        return that.$message.error("请先前往绑定银行卡！");
      }
      that
        .$http({
          //调用接口
          method: "POST",
          headers: {
            "Content-Type": "application/json; charset=UTF-8"
          },
          data: that.param,
          url: that.$serverUrl + "withdraw"
        })
        .then(
          res => {
            this.param = res.data.data;
               if (res.data.msg == "success") {
              that.$message.success("提现成功！");
              that.$router.go(-1);
            } else {
              that.$message.error(res.data.msg);
            }
          },
          function(error) {}
        );
    },
    withdraw() {
      var that = this;
      that
        .$http({
          //调用接口
          method: "GET",
          headers: {
            "Content-Type": "application/json; charset=UTF-8"
          },
          //   data:that.list,
          url: that.$serverUrl + "user/bank"
        })
        .then(
          res => {
            this.bankNo = res.data.data.bankNo;
          },
          function(error) {}
        );
    },
  }
};
</script>


<style scoped>
.withdrawnext_content {
  width: 95%;
  height: 6rem;
  background: #fff;
  margin: 1rem auto;
  border-radius: 10px;
  box-shadow: 0px 0px 10px #ccc;
}
.content_top {
  width: 100%;
  height: 1rem;
  color: #333;
  letter-spacing: 1px;
  font-size: 0.35rem;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.content_input {
  width: 100%;
  height: 1.5rem;
  margin-top: 0.8rem;
  font-size: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid #d3d1d1ab;
}
.content_input input {
  width: 70%;
  height: 1rem;
  padding: 0 0.2rem;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin-left: 0.45rem;
  border: none;
  outline: none;
}
.withdraw_button {
  width: 100%;
  height: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
}
.withdraw_button button {
  width: 5rem;
  height: 0.8rem;
  border: none;
  background: #26a2ff;
  color: #fff;
  letter-spacing: 1px;
  border-radius: 5px;
  outline: none;
}
</style>
